package com.aikon.wht.queue;

import java.util.concurrent.DelayQueue;
import java.util.concurrent.TimeUnit;

/**
 * @author haitao.wang
 */
public class TestOfDelayQueue {

    public static void main(String[] args) throws InterruptedException {
        DelayQueue<DelayModel> delayQueue = new DelayQueue<>();
        delayQueue.add(new DelayModel("A"));
//        Thread.sleep(2000);
        delayQueue.add(new DelayModel("B"));
//        Thread.sleep(2000);
        delayQueue.add(new DelayModel("C"));
        System.out.println(delayQueue.poll(2, TimeUnit.SECONDS).t);
        System.out.println(delayQueue.poll().t);
        System.out.println(delayQueue.poll().t);
    }
}
